package cn.m19.lof.table;

import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.table.TableDef;

import java.io.Serial;

/**
 * 系统账户表表定义层
 * @author lof
 * @since 2025-10-18
 */
public class SysAccountDef extends TableDef {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 系统账户表
     */
    public static final SysAccountDef sysAccount = new SysAccountDef();

    /**
     * ID
     */
    public final QueryColumn id = new QueryColumn(this, "id");

    /**
     * 性别：0-未知; 1-男; 2-女;
     */
    public final QueryColumn sex = new QueryColumn(this, "sex");

    /**
     * 邮箱
     */
    public final QueryColumn email = new QueryColumn(this, "email");

    /**
     * 手机号
     */
    public final QueryColumn phone = new QueryColumn(this, "phone");

    /**
     * 头像
     */
    public final QueryColumn avatar = new QueryColumn(this, "avatar");

    /**
     * 备注
     */
    public final QueryColumn remark = new QueryColumn(this, "remark");

    /**
     * 状态：0-禁用; 1-正常;
     */
    public final QueryColumn status = new QueryColumn(this, "status");

    /**
     * 昵称
     */
    public final QueryColumn nickname = new QueryColumn(this, "nickname");

    /**
     * 密码
     */
    public final QueryColumn password = new QueryColumn(this, "password");

    /**
     * 用户名
     */
    public final QueryColumn username = new QueryColumn(this, "username");

    /**
     * 创建时间
     */
    public final QueryColumn createdAt = new QueryColumn(this, "created_at");

    /**
     * 创建人
     */
    public final QueryColumn createdBy = new QueryColumn(this, "created_by");

    /**
     * 删除时间
     */
    public final QueryColumn deletedAt = new QueryColumn(this, "deleted_at");

    /**
     * 删除人
     */
    public final QueryColumn deletedBy = new QueryColumn(this, "deleted_by");

    /**
     * 更新时间
     */
    public final QueryColumn updatedAt = new QueryColumn(this, "updated_at");

    /**
     * 更新人
     */
    public final QueryColumn updatedBy = new QueryColumn(this, "updated_by");

    /**
     * 最后登录时间
     */
    public final QueryColumn lastLoginAt = new QueryColumn(this, "last_login_at");

    /**
     * 所有字段
     */
    public final QueryColumn allColumns = new QueryColumn(this, "*");

    /**
     * 默认字段, 不包含逻辑删除或者large等字段
     */
    public final QueryColumn[] defaultColumns = new QueryColumn[]{id, username, password, nickname, email, phone, sex, avatar, status, remark, lastLoginAt, deletedAt, deletedBy, createdAt, createdBy, updatedAt, updatedBy};

    public SysAccountDef() {
        super("", "sys_account");
    }

    private SysAccountDef(String schema, String name, String alisa) {
        super(schema, name, alisa);
    }

    public SysAccountDef as(String alias) {
        String key = getNameWithSchema() + "." + alias;
        return getCache(key, k -> new SysAccountDef("", "sys_account", alias));
    }

}
